<?php
$date = date('d-m-Y');
$customer_info = array(
	'name'		=> $_POST['Name'],
	'phone'		=> $_POST['Phone'],
	'email'		=> $_POST['Email'],
	'message'	=> $_POST['Message']
);

$company_info = array(
	'company_name'		=> $_POST['company_name'],
	'company_address'	=> $_POST['company_address'],
	'company_email'		=> $_POST['company_email'],
	'company_phone'		=> $_POST['company_phone'],
	'company_fax'		=> $_POST['company_fax'],
	'company_content'	=> $_POST['company_message']
);

$send_info = array(
	'sendby'		=> get_option("mySetting_company_name"),
	'sendaddress'	=> get_option("mySetting_company_address"),
	'sendtel'		=> get_option("mySetting_company_tel"),
	'sendemail'		=> get_option("mySetting_company_email")
	);

## gui mail user	
$config_info = array(
	'url'			=> get_bloginfo('home'),
	'name'			=> get_bloginfo('name'),
	'date'			=> $date,
	'subject'		=> 'Travel Agent',
	'contact_name'  => 'Admin',
	'contact_email' => db_get_mail_admin_managerment("email_support_travel_agent"),
	'usermessage'	=> 'Travel Agent Infomation at site ',
	'html_link' 	=> 'xtemplate-email-travel-agent.html'	
);
	
## gui mail khach hang
$result = gui_noi_dung_travel($config_info,$customer_info,$company_info,$send_info,0);
## gui mail admin
$result2 = gui_noi_dung_travel($config_info,$customer_info,$company_info,$send_info,1);

function 	gui_noi_dung_travel($config_info,$customer_info,$company_info,$send_info,$user)
{
                include_once	'xtemplate.class.php';
                $header   		= 'Content-type: text/html; charset=utf-8\r\n';	                               
                $parseTemplate	=	new XTemplate($config_info['html_link']);
                
                if($user==1) ## admin
                {
                	$contact_name 	= $config_info['contact_name'];
                	$contact_email  = $config_info['contact_email'];
                }
                else
                { 
                    $contact_name 	= $customer_info['name'];
                    $contact_email  = $customer_info['email'];
                }
                    
                $usermessage  	= $config_info['usermessage'];
                $subject		= $config_info['subject'];               
                
                $parseTemplate->assign('subject',$subject);
                $parseTemplate->assign('url', $config_info['link']);
                $parseTemplate->assign('name',$config_info['name']);
                $parseTemplate->assign('contact_name',$contact_name);
                $parseTemplate->assign('date',$config_info['date']);
                $parseTemplate->assign('usermessage',$usermessage);                
                
                ## thong tin khach hang
                $parseTemplate->assign('fullname',$customer_info['name']);                
                $parseTemplate->assign('email',$contact_email);	
                $parseTemplate->assign('phone',$customer_info['phone']);                
                $parseTemplate->assign('content', $customer_info['message']);
                
                 ## thong tin company
                $parseTemplate->assign('company_name',$company_info['company_name']);
                $parseTemplate->assign('company_address',$company_info['company_address']);                 
                $parseTemplate->assign('company_email',$company_info['company_email']);	
                $parseTemplate->assign('company_phone',$company_info['company_phone']);
                $parseTemplate->assign('company_fax',$company_info['company_fax']);                 
                $parseTemplate->assign('company_content', $company_info['company_content']);
                
                ## gui sendby
                $parseTemplate->assign('sendby', $send_info['sendby']);
                $parseTemplate->assign('sendaddress', $send_info['sendaddress']);
                $parseTemplate->assign('sendtel', $send_info['sendtel']);
                $parseTemplate->assign('sendemail', $send_info['sendemail']);
                	
                ## gui mail
                $parseTemplate->parse('main');                	
               	if(wp_mail($contact_email, $subject, $parseTemplate->text('main'), $header))
               		return true;
               	return false;
                	
            }